print "Install runtime.ear from script package"
omsserver=AdminConfig.list("Server","server1.*")

# First check if the app is deployed already..
appfound="false"
apps=AdminApp.list()
applist = apps.split(lineSeparator)
if applist:
	for app in applist:
		if app == "SterlingRuntime":
			appfound="true"
			break

#iif it was found,  let's remove it and then reinstall it
if appfound == "true":
	print "Removing existing SterlingRuntime application"
	AdminApp.uninstall(app)	
	AdminConfig.save()


AdminApp.install('/tmp/<%=@earName%>', '[ -nopreCompileJSPs -distributeApp -nouseMetaDataFromBinary -appname "SterlingRuntime" -createMBeansForResources -noreloadEnabled -nodeployws -validateinstall warn -noprocessEmbeddedConfig -filepermission .*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755 -noallowDispatchRemoteInclude -noallowServiceRemoteInclude -asyncRequestDispatchType DISABLED -nouseAutoLink -MapModulesToServers [<%=@warlist%>]]' ) 

print "Save config changes."
AdminConfig.save()
print "Done saving config changes."

print "start SterlingRuntime application on omsserver"

appManager = AdminControl.queryNames('cell=*,node=*,type=ApplicationManager,process=*,*')
AdminControl.completeObjectName('cell=*,node=*,type=ApplicationManager,process=*,*')
AdminControl.invoke(appManager,'startApplication','SterlingRuntime')


